package cn.deepmax.anime.web.support;

import cn.deepmax.anime.web.Constant;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;

public class PhantomJSDriverFactory implements WebDriverFactory<PhantomJSDriver> {

    @Override
    public PhantomJSDriver newInstance() {
        DesiredCapabilities dcaps = new DesiredCapabilities();//设置必要参数
        dcaps.setCapability("acceptSslCerts", true);  //ssl证书支持
        dcaps.setCapability("takesScreenshot", false); //截屏支持
        dcaps.setCapability("cssSelectorsEnabled", true); //css搜索支持
        dcaps.setJavascriptEnabled(true);  //js支持
        dcaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, Constant.PHANTOM_EXE);  //驱动支持
        PhantomJSDriver driver = new PhantomJSDriver(dcaps);
        return  driver;
    }
}
